package com.dtxy.data;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * Created by MANGOCOOL on 2015/9/29.
 */
public class XdbHost {

    public static Properties pro = null;

    static
    {
        InputStream in = XdbHost.class.getClassLoader().getResourceAsStream("xdbHost.properties");
        pro = new Properties();
        try {
            pro.load(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static String getAddress(String key)
    {
        return getProperty(key)!=null? getProperty(key): "192.168.21.11";
    }

    public static int getPort(String key)
    {
        return Integer.parseInt(getProperty(key)!=null? getProperty(key): "8011");
    }

    public static int getTimeout(String key)
    {
        return Integer.parseInt(getProperty(key)!=null? getProperty(key): "100000");
    }

    public static String getMaster(String key)
    {
        return getProperty(key)!=null? getProperty(key): "spark://h86:7077";
    }

    private static String getProperty(String key)
    {
        return pro.getProperty(key);
    }

    public static void main(String[] args) {
        System.out.println(getProperty("xdbAddress") + " " + getProperty("port") + " " +  getProperty("timeout") + " " +  getProperty("sparkMaster"));
    }
}
